<template>
  <el-dialog v-if="visible" :title="info.title" :visible.sync="visible" append-to-body center width="760px" :before-close="handleCancel">
    <el-form ref="formDate" label-suffix=":" label-width="120px" :rules="rules" :model="form">
      <el-row>
        <el-col :span="12">
          <el-form-item label="离职日期" prop="quit_time">
            <el-date-picker
              v-model="form.quit_time"
              format="yyyy-MM-dd"
              value-format= "yyyy-MM-dd"
              type="date"
              size="small"
              clearable
              style="width: 100%"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="交接说明" prop="handover">
            <el-input v-model="form.handover" type="textarea" :rows="4" size="small" clearable style="width: 100%" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="离职原因" prop="reason">
            <el-input v-model="form.reason" type="textarea" :rows="4" size="small" clearable style="width: 100%" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="附件上传" prop="files">
            <Upload v-model="form.files" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="备注" prop="remark">
            <el-input v-model="form.remark" type="textarea" :rows="4" size="small" clearable style="width: 100%" />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="24">
          <el-form-item label="抄送" prop="ccs">
            <VerifyCC v-model="form.ccs" :ccs="ccs" />
          </el-form-item>
        </el-col> -->
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="fr mt10">
            <el-button size="small" @click="handleCancel()">取 消</el-button>
            <el-button type="primary" size="small" @click="handleBeforeTo()">提 交</el-button>
          </div>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</template>

<script>
import Upload from '@/myComponents/Upload'
// import VerifyCC from '@/myComponents/VerifyCC'
import svf from '../../util/svf'

export default {
  components: { Upload },
  extends: svf,
  data() {
    return {
      approve_key: 'PROCESS_QUIT',
      rules: {
        quit_time: [{ required: true, trigger: 'blur', message: '请输入离职日期' }],
        handover: [{ required: true, trigger: 'blur', message: '请输入交接说明' }],
        reason: [{ required: true, trigger: 'blur', message: '请输入离职原因' }]
      }
    }
  },
  watch: {
    visible(val) {
      if (val) {
        if(this.info.type && this.info.type === 'again'){
          this.initApply(this.info.edit)
        }else{
          this.form = this.info.edit
        }
        // this.queryCcs()
      }
    }
  },
  mounted() {
  },
  methods: {
    handleBeforeTo() {
      this.validate().then(() => {
        const e = {}
        e.files = this.form.files
        e.approve_key = this.approve_key

        e.des = '离职日期: ' + this.form.quit_time
        e.des += ' 备注：'
        e.des += this.form.remark

        e.ccs = this.form.ccs
        e.forms = JSON.stringify(this.createForms([
          ['离职日期', this.form.quit_time, this.form.quit_time, 'quit_time'],
          ['交接说明', this.form.handover, this.form.handover, 'handover'],
          ['离职原因', this.form.reason, this.form.reason, 'reason'],
          ['备注', this.form.remark, this.form.remark, 'remark']
        ]))
        this.handleCreate(e)
      })
    }
  }
}
</script>

<style>
</style>
